import request from '@/utils/request'

export const ideaDashboard = {
  list () {
    return request({
      url: '/v1/idea_definitions',
      method: 'get'
    })
  },
  read (id) {
    return request({
      url: '/v1/idea_definitions/' + id,
      method: 'get'
    })
  },
  delete (id) {
    return request({
      url: '/v1/idea_definitions/' + id,
      method: 'delete'
    })
  },
  update (id, data) {
    return request({
      url: '/v1/idea_definitions/' + id,
      method: 'put',
      data: {
        idea_definition: data
      }
    })
  },
  create (data) {
    return request({
      url: '/v1/idea_definitions',
      method: 'post',
      data: {
          idea_definition: data
      }
    })
  },
  getChannels () {
    return request({
      url: '/v1/slack/channels',
      method: 'get'
    })
  },
  getUsers (channelids) {
    return request({
      url: '/v1/slack/users',
      method: 'get',
      params: {
        channels: channelids
      }
    })
  }
}
export const ideaAnswer = {
  read (id) {
    return request({
      url: '/v1/ideas/' + id,
      method: 'get'
    })
  },
  update (id,data) {
    return request({
      url: `/v1/ideas/${id}/answer`,
      method: 'post',
        data
    })
  }
}
export const ideaTemplates = {
  list () {
    return request({
      url: '/v1/idea_templates',
      method: 'get'
    })
  },
  read (id) {
    return request({
      url: '/v1/idea_templates/' + id,
      method: 'get'
    })
  }
}
export const ideaReports = {
  list () {
    return request({
      url: '/v1/idea_reports',
      method: 'get'
    })
  },
  read (id) {
    return request({
      url: '/v1/idea_reports/' + id,
      method: 'get'
    })
  },
  answerComment (answerId, content) {
    return request({
      url: '/v1/question_answers/' + answerId + '/comments',
      method: 'post',
      data: {
        content
      }
    })
  },
  deleteComment (answerId, commentId) {
    return request({
      url: '/v1/question_answers/' + answerId + '/comments/' + commentId,
      method: 'delete'
    })
  },
  vote (id) {
    return request({
      url: '/v1/question_answers/' + id + '/vote',
      method: 'post'
    })
  }
}

export const ideaSetting = {
  timezonesList () {
    return request({
      url: '/v1/settings/timezones',
      method: 'get'
    })
  },

  checkNoticeConnect() {
      return request({
          url: '/v1/integration/notion/check',
          method: 'get'
      })
  },
  connect() {
      return request({
          url: '/v1/integration/notion/connect',
          method: 'get'
      })
  },
  dbList() {
    return request({
        url: '/v1/integration/notion/dblist',
        method: 'get'
    })
  },
  export(data) {
    return request({
        url: '/v1/integration/notion/export',
        method: 'post',
        data
    })
  }
}

export function login () {
  return request({
    url: '/v1/logout',
    method: 'post'
  })
}

export function logout () {
  return request({
    url: '/v1/logout',
    method: 'post'
  })
}

export function getUserProfile() {
    return request({
        url: '/v1/profile',
        method: 'get'
    })
}

export function loginAuth (params) {
  return request({
    url: '/v1/slack/oauth_authorize',
    method: 'get',
    params
  })
}
